/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package proyecto2;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

/**
 *
 * @author Damian
 */
public class VConexion extends javax.swing.JFrame {

    /**
     * Creates new form VConexion
     */
    public VConexion() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtIP = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        txtPuerto = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        lblEstado = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        rbtnCliente = new javax.swing.JRadioButton();
        rbtnServidor = new javax.swing.JRadioButton();
        jPanel3 = new javax.swing.JPanel();
        btnCon = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        setTitle("Conexión");
        setAlwaysOnTop(true);
        setType(java.awt.Window.Type.UTILITY);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos"));
        jPanel2.setLayout(new java.awt.GridLayout(3, 2, 5, 5));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("IP:");
        jPanel2.add(jLabel1);

        txtIP.setText("127.0.0.1");
        jPanel2.add(txtIP);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Puerto:");
        jPanel2.add(jLabel2);

        txtPuerto.setText("3360");
        jPanel2.add(txtPuerto);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Estado:");
        jPanel2.add(jLabel3);

        lblEstado.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblEstado.setForeground(new java.awt.Color(0, 153, 255));
        lblEstado.setText("Esperando...");
        jPanel2.add(lblEstado);

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Actuar como"));
        jPanel1.setLayout(new java.awt.GridLayout(2, 2, 5, 5));

        buttonGroup1.add(rbtnCliente);
        rbtnCliente.setSelected(true);
        rbtnCliente.setText("Cliente");
        rbtnCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtnClienteActionPerformed(evt);
            }
        });
        jPanel1.add(rbtnCliente);

        buttonGroup1.add(rbtnServidor);
        rbtnServidor.setText("Servidor");
        rbtnServidor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtnServidorActionPerformed(evt);
            }
        });
        jPanel1.add(rbtnServidor);

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        btnCon.setText("Conectar");
        jPanel3.add(btnCon);

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(evt);
            }
        });
        jPanel3.add(btnCancelar);

        getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void rbtnClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtnClienteActionPerformed
        if (rbtnCliente.isSelected()) {
            txtIP.setEnabled(true);
            btnCon.setText("Conectar");
        } else {
            txtIP.setEnabled(false);
            txtIP.setText("127.0.0.1");
            btnCon.setText("Escuchar");
        }
    }//GEN-LAST:event_rbtnClienteActionPerformed

    private void rbtnServidorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtnServidorActionPerformed
        if (rbtnCliente.isSelected()) {
            txtIP.setEnabled(true);
            btnCon.setText("Conectar");
        } else {
            txtIP.setEnabled(false);
            txtIP.setText("127.0.0.1");
            btnCon.setText("Escuchar");
        }
    }//GEN-LAST:event_rbtnServidorActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        System.exit(0);
    }//GEN-LAST:event_btnCancelarActionPerformed

    public JButton getBtnCancelar() {
        return btnCancelar;
    }

    public JButton getBtnCon() {
        return btnCon;
    }

    public JLabel getLblEstado() {
        return lblEstado;
    }

    public JRadioButton getRbtnCliente() {
        return rbtnCliente;
    }

    public JRadioButton getRbtnServidor() {
        return rbtnServidor;
    }

    public JTextField getTxtIP() {
        return txtIP;
    }

    public JTextField getTxtPuerto() {
        return txtPuerto;
    }

    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(VConexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(VConexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(VConexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(VConexion.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VConexion().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnCon;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JLabel lblEstado;
    private javax.swing.JRadioButton rbtnCliente;
    private javax.swing.JRadioButton rbtnServidor;
    private javax.swing.JTextField txtIP;
    private javax.swing.JTextField txtPuerto;
    // End of variables declaration//GEN-END:variables
}
